import { Request } from 'express';
import { User } from './objects/user';

export interface AuthenticatedRequest extends Request {
	user: User;
}

export interface Session extends Express.Session {
	name?: string;
	redirection?: string;
	lastHeartbeatTime?: number;
}

export interface RegisterSession extends Express.Session {
	challengeAnswer: string;
}

export interface PostResponse {
	error: number;
	data: any;
}

export class FailedResponse implements PostResponse {
	constructor(what: string, code: number = -1) {
		this.error = code;
		this.data = {
			what: what,
		};
	}

	public data: any;
	public error: number;
}

export class SuccessfulResponse implements PostResponse {
	constructor(data?: any) {
		this.data = data;
	}

	public data: any;
	public error: number = 0;
}
